{include file="common/header"}
<div id="app" v-cloak>
    <el-curd
        ref="curd"
        :field="field"
        :search-date="false"
        :search-status="[{label: '正常', value: 1}, {label: '屏蔽', value: 0}]"
        :search-catalog="catalog"
        search-keyword="请输入下载标题/描述搜索"
        save-title="新增下载"
        variable="single"
        copy-authority
        preview-authority>
        <template v-slot:search>
            <div class="el-search-item">
                <div class="label">属性标签：</div>
                <div class="value">
                    <el-select v-model="attr" placeholder="查看所有属性" @change="searchData()" size="small" filterable>
                        <el-option label="全部" value=""></el-option>
                        <el-option label="热门" value="ishot"></el-option>
                        <el-option label="置顶" value="istop"></el-option>
                        <el-option label="推荐" value="isrecommend"></el-option>
                    </el-select>
                </div>
            </div>
        </template>
        <template v-slot:dropdown="row">
            <li @click="parent.parentVm.clickMenu('cms/downloaded/index#'+row.id)">查看下载</li>
        </template>
    </el-curd>
</div>
<script>
    var config = {:json_encode($config)};
    var catalog = tree.convertString({:json_encode($catalog)});
    new Vue({
        el: '#app',
        data() {
            return {
                catalog: catalog,
                attr: '',
                field: [
                    {
                        label: '基本信息',
                        field: [
                            {
                                prop: 'id', 
                                label: '编号', 
                                table: false,
                            },
                            {
                                prop: 'cover', 
                                label: '下载封面', 
                                table: {
                                    label: '',
                                    width: '60px', 
                                    is: 'el-image'
                                },
                                form: {
                                    is: 'el-file-select', 
                                    type: 'image', 
                                },
                            },
                            {
                                prop: 'images', 
                                label: '多图介绍', 
                                table: false, 
                                form: {
                                    is: 'el-file-list-select', 
                                    default: [], 
                                }
                            },
                            {
                                prop: 'file', 
                                label: '下载文件', 
                                table: false,
                                form: {
                                    is: 'el-file-select', 
                                    type: 'all',
                                    rules: [
                                        {required: true,  message: '请选择文件'}
                                    ],
                                },
                            },
                            {
                                prop: 'title', 
                                label: '下载名称',
                                table: {sort: true}, 
                                form: {
                                    rules: [
                                        {required: true,  message: '请输入标题'}
                                    ],
                                }
                            },
                            {
                                prop: 'catalog_id', 
                                label: '下载分类', 
                                table: {sort: true}, 
                                form: {
                                    is: 'el-select',
                                    child: {is: 'el-option', value: catalog, props:{label: 'title', value: 'id'}},
                                    default: [],
                                    filterable: true,
                                    multiple: true,
                                    rules: [
                                        {required: true,  message: '请选择分类'}
                                    ],
                                },
                            },
                            {
                                prop: 'c_title', 
                                label: '副标题', 
                                table: false, 
                            },
                            {
                                prop: 'description',
                                label: '简短描述',
                                table: false, 
                                form: {
                                    type: 'textarea',
                                }
                            },
                            {
                                prop: 'clicks', 
                                label: '虚拟浏览量', 
                                table: {
                                    label: '浏览量', 
                                    sort: true, 
                                },
                                form: {
                                    default: 0, 
                                }
                            },
                            {
                                prop: 'sort', 
                                label: '下载排序', 
                                table: {is: 'el-input', sort: true},
                                form: {
                                    default: 0, 
                                    placeholder: '降序排序，值越大越靠前，留空则自动增长',
                                },
                            },
                            {
                                prop: 'status', 
                                label: '是否显示',  
                                table: {is: 'el-switch', sort: true},
                                form: {
                                    is: 'el-switch',
                                    default: 1, 
                                },
                            },
                            {
                                prop: 'create_time', 
                                label: '发布时间',  
                                table: false, 
                                form: {
                                    is: 'el-date-picker',
                                    type: 'datetime',
                                	format: 'yyyy-MM-dd HH:mm:ss',
                                	valueFormat: 'yyyy-MM-dd HH:mm:ss',
                                },
                            },
                            {
                                prop: 'relation', 
                                label: '关联下载', 
                                table: false,
                                form: {
                                    is: 'el-select',
                                    child: {
                                        value: [], 
                                        props: {label: 'title', value: 'id'}
                                    },
                                    multiple: true,
                                    filterable: true,
                                    remote: 'cms/download/index',
                                    default: [],
                                    placeholder: '请输入关键词搜索选择，可多选'
                                },
                            },
                            {
                                prop: 'group_id', 
                                label: '下载权限',
                                table: false,
                                form: {
                                    is: 'el-select', 
                                    child: {is: 'el-option',value: {:json_encode($group)}, props:{label: 'title', value: 'id'}},
                                    default: [],
                                    multiple: true,
                                    placeholder: '不设置权限则留空',
                                },
                            },
                            {
                                prop: 'attr', 
                                label: '下载属性',  
                                form: {
                                    is: 'el-checkbox-group', 
                                    child: {is: 'el-checkbox',value: [{label: '置顶'},{label: '推荐'},{label: '热门'}]},
                                    default: [],
                                    multiple: true,
                                },
                            },
                            {
                                prop: 'field', 
                                label: '', 
                                table: false,
                                form: {
                                    labelWidth: '0px',
                                    is: 'el-field', 
                                    default: typeof config.download_field == 'undefined' ? [] : config.download_field, 
                                    ifset: false
                                }
                            },
                        ],
                    },
                    {
                        label: '下载详情',
                        field: [
                            {
                                prop: 'content', 
                                label: '', 
                                table: false, 
                                form: {
                                    labelWidth: '0px',
                                    is: 'el-editor',
                                },
                            },
                        ]
                    },
                    {
                        label: 'TDK设置',
                        field: [
                            {
                                prop: 'seo_url', 
                                label: 'SEO路由', 
                                table: false,
                                form: {placeholder: '只能是字母、数字、下划线、-组合',maxlength: 255}
                            },
                            {
                                prop: 'seo_title', 
                                label: 'SEO标题', 
                                table: false,
                                form: {maxlength: 72}
                            },
                            {
                                prop: 'seo_keywords', 
                                label: 'SEO关键词', 
                                table: false,
                                form: {maxlength: 120}
                            },
                            {
                                prop: 'seo_description',
                                label: 'SEO描述', 
                                table: false,
                                form: {
                                    type: 'textarea', 
                                    maxlength: 240,
                                },
                            },
                        ],
                    }
                ],
            }
        },
        methods: {
            searchData() {
                this.$refs.curd.search = Object.assign({}, this.$refs.curd.search, {page: 1, attr: this.attr});
            },
        }
    });
</script>
{include file="common/footer"}